package cc.fs.video.myvideoproject.utils

/**
 * Created by fostion on 2015/10/22.
 */
class TimeUtil{
    companion object{
        fun formatVideoTime(t: Int): String {
            val timeBuilder = StringBuilder()
            if(t == 0){
                timeBuilder.append("暂无数据")
                return timeBuilder.toString()
            }

            var time: Int = t / 1000;//获得秒
            var hour: Int = 0
            var minute: Int = 0
            var second: Int = 0
            hour = time / 3600
            if (hour > 0) {
                timeBuilder.append("" + hour + ":")
                time = time.minus(3600 * hour)
            }

            minute = time / 60
            if (minute > 0) {
                if (minute > 9) {
                    timeBuilder.append("" + minute + ":")
                } else {
                    timeBuilder.append("0" + minute + ":")
                }
                time = time.minus(60 * minute)
            } else {
                timeBuilder.append("00:")
            }

            second = time
            if (second > 9) {
                timeBuilder.append("" + second + "")
            } else {
                timeBuilder.append("0" + second)
            }

            return timeBuilder.toString()
        }
    }
}
